﻿using System;
using System.Collections.Generic;

namespace AMS.DataAccess.Sys.BO
{
    [DBTable("TS_User")]
    public class UserInfo
    {
        #region Database Column Fields
        [DBPrimaryKeyColumn("AID", true)]
        public int AID { get; set; }

        [DBColumn("Name")]
        public string Name { get; set; }

        [DBColumn("Alias")]
        public string Alias { get; set; }

        [DBColumn("isSysUser", false, true)]
        public bool isSysUser { get; set; }

        [DBEnumColumn("Sex", typeof(SexEnum))]
        public SexEnum Sex { get; set; }

        [DBColumn("LoginName")]
        public string LoginName { get; set; }

        /// <summary>
        /// 可添加，但更新时忽略这个字段
        /// </summary>
        [DBColumn("Pwd", false, true)]
        public string Pwd { get; set; }

        [DBDateTime("PwdExpireDate", DateTimeType.Date)]
        public DateTime PwdExpireDate { get; set; }

        [DBColumn("IDCard")]
        public string IDCard { get; set; }

        [DBDateTime("Birthday", DateTimeType.Date)]
        public DateTime Birthday { get; set; }

        [DBColumn("ActiveFlag", false, true)]
        public int ActiveFlag { get; set; }

        [DBColumn("isReadOnly", false, true)]
        public bool isReadOnly { get; set; }

        [DBColumn("WorkNumber")]
        public string WorkNumber { get; set; }

        [DBColumn("Mobile")]
        public string Mobile { get; set; }

        [DBColumn("Tel")]
        public string Tel { get; set; }

        [DBColumn("Email")]
        public string Email { get; set; }

        [DBColumn("QQ")]
        public string QQ { get; set; }

        [DBColumn("MSN")]
        public string MSN { get; set; }

        [DBColumn("Note")]
        public string Note { get; set; }

        [DBColumn("Picture")]
        public Guid Picture { get; set; }

        [DBColumn("isPatentAttoney")]
        public bool isPatentAttoney { get; set; }

        [DBColumn("isTrademarkAttoney")]
        public bool isTrademarkAttoney { get; set; }

        [DBDateTime("CreateDateTime", DateTimeType.DateTime, false, true)]
        public DateTime CreateDateTime { get; set; }

        [DBColumn("CreateUserID", 0, false, true)]
        public int CreateUserID { get; set; }

        [DBDateTime("ModifiedDateTime", DateTimeType.DateTime, true, false)]
        public DateTime ModifiedDateTime { get; set; }

        [DBColumn("ModifiedUserID", 0, true, false)]
        public int ModifiedUserID { get; set; }

        [DBVersionColumn("Version")]
        public int Version { get; set; }

        [DBForignKeyColumn("DeptID", "TS_Dept")]
        public int DeptID { get; set; }
        #endregion

        public string DisplayName
        {
            get
            {
                if (!string.IsNullOrEmpty(WorkNumber))
                {
                    return Name + " (" + WorkNumber + ")";
                }
                else
                {
                    return Name;
                }
            }
        }

        public List<RoleInfo> Roles { get; set; }
        public List<FunctionInfo> PriorityFunctions { get; set; }
        public DeptInfo Dept { get; set; }
    }
}
